@blueking/ai-ui-sdk 0.0.14 → 0.0.15-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/images/ai.png +0 -0
- package/dist/assets/images/user.png +0 -0
- package/dist/assets/svg/picture-fail.svg +1 -0
- package/dist/common/chart-helper.d.ts +1 -1
- package/dist/common/chart-helper.js +173 -0
- package/dist/common/util.d.ts +31 -0
- package/dist/common/util.js +177 -0
- package/dist/component/render-image/index.script.vue.js +37 -0
- package/dist/component/render-image/index.vue.d.ts +6 -0
- package/dist/component/render-image/index.vue.js +3 -0
- package/dist/component/render-input/index.script.vue.js +205 -0
- package/dist/component/render-input/index.vue.css +134 -0
- package/dist/component/render-input/index.vue.d.ts +18 -0
- package/dist/component/render-input/index.vue.js +5 -0
- package/dist/component/render-input/render-drag.script.vue.js +61 -0
- package/dist/component/render-input/render-drag.vue.css +32 -0
- package/dist/component/render-input/render-drag.vue.d.ts +13 -0
- package/dist/component/render-input/render-drag.vue.js +5 -0
- package/dist/component/render-input/render-quill.script.vue.js +197 -0
- package/dist/component/render-input/render-quill.vue.css +27 -0
- package/dist/component/render-input/render-quill.vue.d.ts +24 -0
- package/dist/component/render-input/render-quill.vue.js +4 -0
- package/dist/component/render-knowledge-icon/index.script.vue.js +40 -0
- package/dist/component/render-knowledge-icon/index.vue.css +4 -0
- package/dist/component/render-knowledge-icon/index.vue.d.ts +14 -0
- package/dist/component/render-knowledge-icon/index.vue.js +5 -0
- package/dist/component/render-markdown/mark-down-code.d.ts +2 -0
- package/dist/component/render-markdown/mark-down-code.js +171 -0
- package/dist/component/render-markdown/mark-down-emoji.d.ts +2 -0
- package/dist/component/render-markdown/mark-down-emoji.js +4 -0
- package/dist/component/render-markdown/mark-down.d.ts +74 -0
- package/dist/component/render-markdown/mark-down.js +147 -0
- package/dist/component/render-markdown/mark-down.postcss.css +131 -0
- package/dist/component/render-message/image-not-supported-message.script.vue.js +99 -0
- package/dist/component/render-message/image-not-supported-message.vue.css +66 -0
- package/dist/component/render-message/image-not-supported-message.vue.d.ts +21 -0
- package/dist/component/render-message/image-not-supported-message.vue.js +5 -0
- package/dist/component/render-message/index.script.vue.js +104 -0
- package/dist/component/render-message/index.vue.d.ts +13 -0
- package/dist/component/render-message/index.vue.js +3 -0
- package/dist/component/render-message/openai-message.script.vue.js +215 -0
- package/dist/component/render-message/openai-message.vue.css +98 -0
- package/dist/component/render-message/openai-message.vue.d.ts +15 -0
- package/dist/component/render-message/openai-message.vue.js +5 -0
- package/dist/component/render-message/skeleton-message.script.vue.js +7 -0
- package/dist/component/render-message/skeleton-message.vue.css +7 -0
- package/dist/component/render-message/skeleton-message.vue.d.ts +2 -0
- package/dist/component/render-message/skeleton-message.vue.js +6 -0
- package/dist/component/render-message/system-message.script.vue.js +17 -0
- package/dist/component/render-message/system-message.vue.css +20 -0
- package/dist/component/render-message/system-message.vue.d.ts +6 -0
- package/dist/component/render-message/system-message.vue.js +5 -0
- package/dist/component/render-message/time-message.script.vue.js +41 -0
- package/dist/component/render-message/time-message.vue.css +14 -0
- package/dist/component/render-message/time-message.vue.d.ts +6 -0
- package/dist/component/render-message/time-message.vue.js +5 -0
- package/dist/component/render-message/token-expired-message.script.vue.js +78 -0
- package/dist/component/render-message/token-expired-message.vue.css +60 -0
- package/dist/component/render-message/token-expired-message.vue.d.ts +15 -0
- package/dist/component/render-message/token-expired-message.vue.js +5 -0
- package/dist/component/render-message/user-message.script.vue.js +241 -0
- package/dist/component/render-message/user-message.vue.css +100 -0
- package/dist/component/render-message/user-message.vue.d.ts +21 -0
- package/dist/component/render-message/user-message.vue.js +5 -0
- package/dist/css/fonts/iconcool.eot +0 -0
- package/dist/css/fonts/iconcool.svg +53 -0
- package/dist/css/fonts/iconcool.ttf +0 -0
- package/dist/css/fonts/iconcool.woff +0 -0
- package/dist/css/iconcool.js +10 -0
- package/dist/css/style.css +43 -0
- package/dist/event/index.d.ts +4 -0
- package/dist/event/index.js +18 -0
- package/dist/hooks/use-chat.d.ts +844 -20
- package/dist/hooks/use-chat.js +565 -0
- package/dist/hooks/use-click-proxy.js +77 -0
- package/dist/hooks/use-http.d.ts +15 -0
- package/dist/hooks/use-http.js +48 -0
- package/dist/hooks/use-mouse-drag.d.ts +13 -0
- package/dist/hooks/use-mouse-drag.js +59 -0
- package/dist/hooks/use-reference-doc.d.ts +1 -1
- package/dist/hooks/use-reference-doc.js +185 -0
- package/dist/hooks/use-style.js +11 -0
- package/dist/hooks/use-summary.d.ts +1 -1
- package/dist/hooks/use-summary.js +55 -0
- package/dist/hooks/use-think.js +135 -0
- package/dist/http/fetch/error-interceptor.d.ts +3 -0
- package/dist/http/fetch/error-interceptor.js +28 -0
- package/dist/http/fetch/index.d.ts +25 -0
- package/dist/http/fetch/index.js +182 -0
- package/dist/http/fetch/request-error.d.ts +6 -0
- package/dist/http/fetch/request-error.js +25 -0
- package/dist/http/fetch/success-interceptor.d.ts +3 -0
- package/dist/http/fetch/success-interceptor.js +92 -0
- package/dist/http/helper/knowledge.d.ts +43 -0
- package/dist/http/helper/knowledge.js +227 -0
- package/dist/http/helper/permission.d.ts +7 -0
- package/dist/http/helper/permission.js +28 -0
- package/dist/http/helper/session.d.ts +31 -0
- package/dist/http/helper/session.js +147 -0
- package/dist/http/helper/tool.d.ts +13 -0
- package/dist/http/helper/tool.js +49 -0
- package/dist/main.d.ts +17 -2
- package/dist/main.js +29 -239
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-down-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-left-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-right-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-double-up-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-down.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-up-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/angle-up.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/archive-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/arrows-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/arrows-right.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/assistant.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/audio-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/bk.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/circle.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/close-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/close.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/code.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/cog-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/collapse-left.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/copy-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/copy.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/data-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/del.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/doc-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/done.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/down-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/down-small.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/edit-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/ellipsis.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/enlarge-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/error.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/excel-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/exclamation-circle-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/eye.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/filliscreen-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/fix-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/fix-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-open.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-shape-open.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/folder.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/funnel.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/grag-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help-document-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/help.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/image-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/img-error.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/img-placehoulder.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/index.js +113 -0
- package/dist/node_modules/bkui-vue/lib/icon/info-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/info.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/left-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/left-turn-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/loading.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/narrow-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/original.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/pdf-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/play-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/plus.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/ppt-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/qq.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/right-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/right-turn-line.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/search.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/share.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/spinner.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/success.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/switcher-loading.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-all.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-file.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/text-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/transfer.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/tree-application-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/unfull-screen.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/unvisible.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/up-shape.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/upload.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/video-fill.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/warn.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/weixin-pro.js +191 -0
- package/dist/node_modules/bkui-vue/lib/icon/weixin.js +191 -0
- package/dist/node_modules/bkui-vue/lib/styles/reset.css +439 -0
- package/dist/node_modules/call-bind/index.js +24 -0
- package/dist/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/dist/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/dist/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/dist/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/dist/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/dist/node_modules/call-bound/index.js +19 -0
- package/dist/node_modules/deep-equal/index.js +112 -0
- package/dist/node_modules/define-data-property/index.js +56 -0
- package/dist/node_modules/define-properties/index.js +47 -0
- package/dist/node_modules/dunder-proto/get.js +30 -0
- package/dist/node_modules/es-define-property/index.js +14 -0
- package/dist/node_modules/es-errors/eval.js +4 -0
- package/dist/node_modules/es-errors/index.js +4 -0
- package/dist/node_modules/es-errors/range.js +4 -0
- package/dist/node_modules/es-errors/ref.js +4 -0
- package/dist/node_modules/es-errors/syntax.js +4 -0
- package/dist/node_modules/es-errors/type.js +4 -0
- package/dist/node_modules/es-errors/uri.js +4 -0
- package/dist/node_modules/es-object-atoms/index.js +4 -0
- package/dist/node_modules/extend/index.js +117 -0
- package/dist/node_modules/fast-diff/diff.js +738 -0
- package/dist/node_modules/function-bind/implementation.js +84 -0
- package/dist/node_modules/function-bind/index.js +5 -0
- package/dist/node_modules/functions-have-names/index.js +31 -0
- package/dist/node_modules/get-intrinsic/index.js +378 -0
- package/dist/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/dist/node_modules/get-proto/index.js +27 -0
- package/dist/node_modules/gopd/gOPD.js +4 -0
- package/dist/node_modules/gopd/index.js +15 -0
- package/dist/node_modules/has-property-descriptors/index.js +22 -0
- package/dist/node_modules/has-symbols/index.js +14 -0
- package/dist/node_modules/has-symbols/shams.js +45 -0
- package/dist/node_modules/has-tostringtag/shams.js +8 -0
- package/dist/node_modules/hasown/index.js +8 -0
- package/dist/node_modules/is-arguments/index.js +44 -0
- package/dist/node_modules/is-date-object/index.js +27 -0
- package/dist/node_modules/is-regex/index.js +69 -0
- package/dist/node_modules/math-intrinsics/abs.js +4 -0
- package/dist/node_modules/math-intrinsics/floor.js +4 -0
- package/dist/node_modules/math-intrinsics/isNaN.js +6 -0
- package/dist/node_modules/math-intrinsics/max.js +4 -0
- package/dist/node_modules/math-intrinsics/min.js +4 -0
- package/dist/node_modules/math-intrinsics/pow.js +4 -0
- package/dist/node_modules/math-intrinsics/round.js +4 -0
- package/dist/node_modules/math-intrinsics/sign.js +11 -0
- package/dist/node_modules/object-is/implementation.js +19 -0
- package/dist/node_modules/object-is/index.js +18 -0
- package/dist/node_modules/object-is/polyfill.js +7 -0
- package/dist/node_modules/object-is/shim.js +14 -0
- package/dist/node_modules/object-keys/implementation.js +122 -0
- package/dist/node_modules/object-keys/index.js +32 -0
- package/dist/node_modules/object-keys/isArguments.js +17 -0
- package/dist/node_modules/quill/dist/quill.js +11562 -0
- package/dist/node_modules/quill/dist/quill.snow.css +945 -0
- package/dist/node_modules/quill-delta/lib/delta.js +344 -0
- package/dist/node_modules/quill-delta/lib/op.js +155 -0
- package/dist/node_modules/regexp.prototype.flags/implementation.js +39 -0
- package/dist/node_modules/regexp.prototype.flags/index.js +18 -0
- package/dist/node_modules/regexp.prototype.flags/polyfill.js +39 -0
- package/dist/node_modules/regexp.prototype.flags/shim.js +26 -0
- package/dist/node_modules/set-function-length/index.js +42 -0
- package/dist/node_modules/set-function-name/index.js +23 -0
- package/dist/node_modules/x-mavon-editor/dist/css/index.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.eot +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.svg +72 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/font/fontello.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/highlight.min.js +1150 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/bash.min.js +20 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/css.min.js +31 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/go.min.js +14 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/java.min.js +37 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/javascript.min.js +76 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/json.min.js +7 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/markdown.min.js +31 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/perl.min.js +36 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/php.min.js +37 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/python.min.js +42 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/ruby.min.js +48 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/sql.min.js +17 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/swift.min.js +60 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/typescript.min.js +92 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/languages/xml.min.js +28 -0
- package/dist/node_modules/x-mavon-editor/dist/highlightjs/styles/atom-one-dark.min.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.css +1 -0
- package/dist/node_modules/x-mavon-editor/dist/katex/katex.min.js +1 -0
- package/dist/node_modules/x-mavon-editor/dist/markdown/github-markdown.min.css +2 -0
- package/dist/node_modules/x-mavon-editor/dist/mavon-editor.js +31 -0
- package/dist/types/enum.d.ts +44 -0
- package/dist/types/enum.js +111 -0
- package/dist/types/file.d.ts +13 -0
- package/dist/types/file.js +1 -0
- package/dist/types/knowledge.d.ts +133 -0
- package/dist/types/knowledge.js +1 -0
- package/dist/types/model.d.ts +14 -0
- package/dist/types/permission.d.ts +48 -0
- package/dist/types/permission.js +1 -0
- package/dist/types/{type.d.ts → session.d.ts} +84 -23
- package/dist/types/session.js +1 -0
- package/dist/types/tool.d.ts +60 -0
- package/dist/types/tool.js +1 -0
- package/package.json +10 -4
- package/dist/common/type-transform.d.ts +0 -7
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><g ><path fill="#979BA5" d="M208 198.88l168 0-7.84 86.08 51.68 87.36L382.4 486.72l114.88-98.4 7.84-112 41.76-78.08H824.64a56 56 0 0 1 51.68 52.8V721.6L747.04 555.36a40.96 40.96 0 0 0-67.36-5.12l-145.76 146.88L384 502.56c-16-20.96-41.76-20.96-62.56 0L150.56 712.96 152 252.48A54.4 54.4 0 0 1 208 198.88M823.84 145.44l-315.04 0-48 134.4 10.08 96.8L416 432l32.96-64-37.28-96 33.76-128-242.56 1.44A106.24 106.24 0 0 0 96 248.16l2.08 524.8A104.64 104.64 0 0 0 200.16 880h624A104.64 104.64 0 0 0 928 775.2V250.24a104.96 104.96 0 0 0-104.16-104.8"/><path fill="#979BA5" d="M569.28 405.44a88.32 88.32 0 0 0 43.04 75.52 84.64 84.64 0 0 0 86.88 0 86.72 86.72 0 0 0 43.04-75.52 88.64 88.64 0 0 0-43.04-75.52 85.44 85.44 0 0 0-86.88 0 88.64 88.64 0 0 0-43.04 75.52"/></g></svg>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Document } from '../types/
|
1
|
+
import type { Document } from '../types/session';
|
2
2
|
type HandleStart = (sessionCode: string) => any;
|
3
3
|
type HandleText = (sessionCode: string, message: string, cover?: boolean) => void;
|
4
4
|
type HandleReferenceDoc = (sessionCode: string, documents: Document[], cover?: boolean) => void;
|
@@ -0,0 +1,173 @@
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
2
|
+
try {
|
3
|
+
var info = gen[key](arg);
|
4
|
+
var value = info.value;
|
5
|
+
} catch (error) {
|
6
|
+
reject(error);
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
if (info.done) {
|
10
|
+
resolve(value);
|
11
|
+
} else {
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
function _async_to_generator(fn) {
|
16
|
+
return function() {
|
17
|
+
var self = this, args = arguments;
|
18
|
+
return new Promise(function(resolve, reject) {
|
19
|
+
var gen = fn.apply(self, args);
|
20
|
+
function _next(value) {
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
22
|
+
}
|
23
|
+
function _throw(err) {
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
25
|
+
}
|
26
|
+
_next(undefined);
|
27
|
+
});
|
28
|
+
};
|
29
|
+
}
|
30
|
+
function _define_property(obj, key, value) {
|
31
|
+
if (key in obj) {
|
32
|
+
Object.defineProperty(obj, key, {
|
33
|
+
value: value,
|
34
|
+
enumerable: true,
|
35
|
+
configurable: true,
|
36
|
+
writable: true
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
obj[key] = value;
|
40
|
+
}
|
41
|
+
return obj;
|
42
|
+
}
|
43
|
+
function _object_spread(target) {
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
46
|
+
var ownKeys = Object.keys(source);
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
50
|
+
}));
|
51
|
+
}
|
52
|
+
ownKeys.forEach(function(key) {
|
53
|
+
_define_property(target, key, source[key]);
|
54
|
+
});
|
55
|
+
}
|
56
|
+
return target;
|
57
|
+
}
|
58
|
+
import { isJSON } from './util.js';
|
59
|
+
export class ChatHelper {
|
60
|
+
stream({ sessionCode, url, headers, data }) {
|
61
|
+
var _this = this;
|
62
|
+
return _async_to_generator(function*() {
|
63
|
+
var _this_handleStart, _this1;
|
64
|
+
// 开始
|
65
|
+
yield (_this_handleStart = (_this1 = _this).handleStart) === null || _this_handleStart === void 0 ? void 0 : _this_handleStart.call(_this1, sessionCode);
|
66
|
+
// 记录 controller
|
67
|
+
const controller = new AbortController();
|
68
|
+
_this.controllerMap[sessionCode] = controller;
|
69
|
+
// 发送请求
|
70
|
+
fetch(url, {
|
71
|
+
method: 'post',
|
72
|
+
signal: controller.signal,
|
73
|
+
headers: _object_spread({
|
74
|
+
'Content-Type': 'application/json'
|
75
|
+
}, headers),
|
76
|
+
mode: 'cors',
|
77
|
+
credentials: 'include',
|
78
|
+
body: JSON.stringify(data)
|
79
|
+
}).then(function() {
|
80
|
+
var _ref = _async_to_generator(function*(response) {
|
81
|
+
const reader = response.body.pipeThrough(new window.TextDecoderStream()).getReader();
|
82
|
+
// 临时存储数据
|
83
|
+
let temp = '';
|
84
|
+
while(true){
|
85
|
+
try {
|
86
|
+
const { value, done } = yield reader.read();
|
87
|
+
// 接口异常处理
|
88
|
+
if (!response.ok) {
|
89
|
+
let message = value || response.statusText;
|
90
|
+
try {
|
91
|
+
const json = JSON.parse(message);
|
92
|
+
message = json.message || json.error.message || message;
|
93
|
+
} catch (error) {
|
94
|
+
console.error(error.message || error);
|
95
|
+
}
|
96
|
+
_this.handleError(sessionCode, message, response.status);
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
// 接口完成
|
100
|
+
if (done) {
|
101
|
+
_this.handleEnd(sessionCode);
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
const values = (temp + value.toString()).split('\n');
|
105
|
+
values.forEach((value)=>{
|
106
|
+
const item = value.replace('data:', '').trim();
|
107
|
+
if (isJSON(item)) {
|
108
|
+
const { event, content, cover, documents, result, code, elapsed_time, message } = JSON.parse(item);
|
109
|
+
// 业务错误处理
|
110
|
+
if (result === false || response.status !== 200) {
|
111
|
+
_this.handleError(sessionCode, message || '模型调用失败', code);
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
switch(event){
|
115
|
+
case 'text':
|
116
|
+
_this.handleText(sessionCode, content, cover);
|
117
|
+
break;
|
118
|
+
case 'reference_doc':
|
119
|
+
var _this_handleReferenceDoc, _this1;
|
120
|
+
(_this_handleReferenceDoc = (_this1 = _this).handleReferenceDoc) === null || _this_handleReferenceDoc === void 0 ? void 0 : _this_handleReferenceDoc.call(_this1, sessionCode, documents, cover);
|
121
|
+
break;
|
122
|
+
case 'think':
|
123
|
+
var _this_handleThink, _this2;
|
124
|
+
(_this_handleThink = (_this2 = _this).handleThink) === null || _this_handleThink === void 0 ? void 0 : _this_handleThink.call(_this2, sessionCode, content, cover, elapsed_time);
|
125
|
+
break;
|
126
|
+
case 'done':
|
127
|
+
_this.handleEnd(sessionCode, cover ? content : '');
|
128
|
+
break;
|
129
|
+
case 'error':
|
130
|
+
_this.handleError(sessionCode, message || '模型调用失败', code);
|
131
|
+
break;
|
132
|
+
}
|
133
|
+
temp = '';
|
134
|
+
} else if (item) {
|
135
|
+
temp = item;
|
136
|
+
}
|
137
|
+
});
|
138
|
+
} catch (error) {
|
139
|
+
if ((error === null || error === void 0 ? void 0 : error.code) !== 20) {
|
140
|
+
_this.handleError(sessionCode, `模型调用失败:${error.message}`, error.code);
|
141
|
+
}
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
});
|
146
|
+
return function(response) {
|
147
|
+
return _ref.apply(this, arguments);
|
148
|
+
};
|
149
|
+
}());
|
150
|
+
})();
|
151
|
+
}
|
152
|
+
stop(sessionCode) {
|
153
|
+
var _this_controllerMap_sessionCode_abort, _this_controllerMap_sessionCode;
|
154
|
+
(_this_controllerMap_sessionCode = this.controllerMap[sessionCode]) === null || _this_controllerMap_sessionCode === void 0 ? void 0 : (_this_controllerMap_sessionCode_abort = _this_controllerMap_sessionCode.abort) === null || _this_controllerMap_sessionCode_abort === void 0 ? void 0 : _this_controllerMap_sessionCode_abort.call(_this_controllerMap_sessionCode);
|
155
|
+
return this.handleEnd(sessionCode);
|
156
|
+
}
|
157
|
+
constructor({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError }){
|
158
|
+
_define_property(this, "handleStart", void 0);
|
159
|
+
_define_property(this, "handleText", void 0);
|
160
|
+
_define_property(this, "handleReferenceDoc", void 0);
|
161
|
+
_define_property(this, "handleThink", void 0);
|
162
|
+
_define_property(this, "handleEnd", void 0);
|
163
|
+
_define_property(this, "handleError", void 0);
|
164
|
+
_define_property(this, "controllerMap", void 0);
|
165
|
+
this.handleStart = handleStart;
|
166
|
+
this.handleText = handleText;
|
167
|
+
this.handleReferenceDoc = handleReferenceDoc;
|
168
|
+
this.handleThink = handleThink;
|
169
|
+
this.handleEnd = handleEnd;
|
170
|
+
this.handleError = handleError;
|
171
|
+
this.controllerMap = {};
|
172
|
+
}
|
173
|
+
}
|
package/dist/common/util.d.ts
CHANGED
@@ -1,9 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* 节流,每隔一段时间执行
|
3
|
+
* @param {*} fn 需要执行的函数
|
4
|
+
* @param {*} delay 延迟时间,默认200
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export declare const throttle: <T1, T2, R>(fn: (p1?: T1, p2?: T2) => R, delay?: number) => (p1?: T1, p2?: T2) => false | undefined;
|
1
8
|
/**
|
2
9
|
* 判断是否是 JSON 字符串
|
3
10
|
* @param str 字符串
|
4
11
|
* @returns 是否是 JSON 字符串
|
5
12
|
*/
|
6
13
|
export declare const isJSON: (str: string) => boolean;
|
14
|
+
/**
|
15
|
+
* 检查是不是 object 类型
|
16
|
+
* @param item
|
17
|
+
* @returns {boolean}
|
18
|
+
*/
|
19
|
+
export declare function isObject(item: any): boolean;
|
20
|
+
/**
|
21
|
+
* 深度合并多个对象
|
22
|
+
* @param objectArray 待合并列表
|
23
|
+
* @returns {object} 合并后的对象
|
24
|
+
*/
|
25
|
+
export declare function deepMerge(...objectArray: object[]): any;
|
26
|
+
export declare const mergeStringWithoutLeadingSlash: (str1?: string, str2?: string) => string;
|
27
|
+
export declare const mergeStringWithoutLastSlash: (str1?: string, str2?: string) => string;
|
7
28
|
/**
|
8
29
|
* 响应时间格式化
|
9
30
|
* @param val 待格式化时间,xxms
|
@@ -30,3 +51,13 @@ export declare const processPromptTemplate: (prompt: string, selectedText: strin
|
|
30
51
|
* @returns 全屏的父元素
|
31
52
|
*/
|
32
53
|
export declare const getFullScreenWrap: (target: HTMLElement) => HTMLElement | null;
|
54
|
+
/**
|
55
|
+
* 获取用户头像
|
56
|
+
* @param username 用户名
|
57
|
+
* @returns 头像地址
|
58
|
+
*/
|
59
|
+
export declare function getUserImageUrl(username?: string): any;
|
60
|
+
/**
|
61
|
+
* 处理头像加载失败的场景
|
62
|
+
*/
|
63
|
+
export declare function handleImageError(event: Event): void;
|
@@ -0,0 +1,177 @@
|
|
1
|
+
import { Message } from 'bkui-vue';
|
2
|
+
import { emitEvent } from '../event/index.js';
|
3
|
+
import { EventType } from '../types/enum.js';
|
4
|
+
import userImageUrl from '../assets/images/user.png';
|
5
|
+
/**
|
6
|
+
* 节流,每隔一段时间执行
|
7
|
+
* @param {*} fn 需要执行的函数
|
8
|
+
* @param {*} delay 延迟时间,默认200
|
9
|
+
* @returns
|
10
|
+
*/ export const throttle = (fn, delay = 200)=>{
|
11
|
+
let valid = true;
|
12
|
+
return function(p1, p2) {
|
13
|
+
if (!valid) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
valid = false;
|
17
|
+
setTimeout(()=>{
|
18
|
+
fn(p1, p2);
|
19
|
+
valid = true;
|
20
|
+
}, delay);
|
21
|
+
};
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* 判断是否是 JSON 字符串
|
25
|
+
* @param str 字符串
|
26
|
+
* @returns 是否是 JSON 字符串
|
27
|
+
*/ export const isJSON = (str)=>{
|
28
|
+
try {
|
29
|
+
JSON.parse(str);
|
30
|
+
return true;
|
31
|
+
} catch (e) {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* 检查是不是 object 类型
|
37
|
+
* @param item
|
38
|
+
* @returns {boolean}
|
39
|
+
*/ export function isObject(item) {
|
40
|
+
return Object.prototype.toString.apply(item) === '[object Object]';
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* 深度合并多个对象
|
44
|
+
* @param objectArray 待合并列表
|
45
|
+
* @returns {object} 合并后的对象
|
46
|
+
*/ export function deepMerge(...objectArray) {
|
47
|
+
return objectArray.reduce((acc, obj)=>{
|
48
|
+
Object.keys(obj || {}).forEach((key)=>{
|
49
|
+
const pVal = acc[key];
|
50
|
+
const oVal = obj[key];
|
51
|
+
if (isObject(pVal) && isObject(oVal)) {
|
52
|
+
acc[key] = deepMerge(pVal, oVal);
|
53
|
+
} else {
|
54
|
+
acc[key] = oVal;
|
55
|
+
}
|
56
|
+
});
|
57
|
+
return acc;
|
58
|
+
}, {});
|
59
|
+
}
|
60
|
+
// 合并字符串,如果是 / 开头就去掉它
|
61
|
+
export const mergeStringWithoutLeadingSlash = (str1 = '', str2 = '')=>{
|
62
|
+
const result = `${str1}/${str2}`;
|
63
|
+
if (result.startsWith('/')) {
|
64
|
+
return result.slice(1);
|
65
|
+
}
|
66
|
+
return result;
|
67
|
+
};
|
68
|
+
// 合并字符串,如果是 / 结尾就去掉它
|
69
|
+
export const mergeStringWithoutLastSlash = (str1 = '', str2 = '')=>{
|
70
|
+
const result = `${str1}/${str2}`;
|
71
|
+
if (result.endsWith('/')) {
|
72
|
+
return result.slice(0, -1);
|
73
|
+
}
|
74
|
+
return result;
|
75
|
+
};
|
76
|
+
/**
|
77
|
+
* 响应时间格式化
|
78
|
+
* @param val 待格式化时间,xxms
|
79
|
+
* @returns 格式化后的时间,xx小时xx分钟xx秒
|
80
|
+
*/ export function durationFormatter(val) {
|
81
|
+
const hours = Math.floor(val / 3600000);
|
82
|
+
const minutes = Math.floor(val % 3600000 / 60000);
|
83
|
+
const seconds = Math.floor(val % 60000 / 1000);
|
84
|
+
const milliseconds = val % 1000;
|
85
|
+
const parts = [];
|
86
|
+
if (hours > 0) {
|
87
|
+
parts.push(`${hours}h`);
|
88
|
+
}
|
89
|
+
if (minutes > 0) {
|
90
|
+
parts.push(`${minutes}min`);
|
91
|
+
}
|
92
|
+
if (seconds > 0) {
|
93
|
+
parts.push(`${seconds}s`);
|
94
|
+
}
|
95
|
+
if (milliseconds > 0) {
|
96
|
+
parts.push(`${milliseconds.toFixed(2)}ms`);
|
97
|
+
}
|
98
|
+
return parts.join(' ');
|
99
|
+
}
|
100
|
+
/**
|
101
|
+
* 前端下载文件
|
102
|
+
* @param {*} source 文件内容
|
103
|
+
* @param {*} filename 文件名
|
104
|
+
*/ export function handleDownLoad(source, filename = 'ai.txt') {
|
105
|
+
const downloadEl = document.createElement('a');
|
106
|
+
const blob = new Blob([
|
107
|
+
source
|
108
|
+
]);
|
109
|
+
downloadEl.download = filename;
|
110
|
+
downloadEl.href = URL.createObjectURL(blob);
|
111
|
+
downloadEl.style.display = 'none';
|
112
|
+
document.body.appendChild(downloadEl);
|
113
|
+
downloadEl.click();
|
114
|
+
document.body.removeChild(downloadEl);
|
115
|
+
}
|
116
|
+
export const handleCopy = (text)=>{
|
117
|
+
const textarea = document.createElement('textarea');
|
118
|
+
textarea.value = text;
|
119
|
+
document.body.appendChild(textarea);
|
120
|
+
textarea.select();
|
121
|
+
document.execCommand('copy');
|
122
|
+
Message({
|
123
|
+
theme: 'success',
|
124
|
+
message: '复制成功'
|
125
|
+
});
|
126
|
+
document.body.removeChild(textarea);
|
127
|
+
};
|
128
|
+
/**
|
129
|
+
* 处理提示词模板,替换模板中的变量
|
130
|
+
* @param prompt 提示词模板
|
131
|
+
* @param selectedText 选中的文本
|
132
|
+
* @returns 处理后的提示词
|
133
|
+
*/ export const processPromptTemplate = (prompt, selectedText)=>{
|
134
|
+
return prompt.replace(/\{\{\s*SELECTED_TEXT\s*\}\}/g, selectedText || '');
|
135
|
+
};
|
136
|
+
/**
|
137
|
+
* 获取全屏的父元素
|
138
|
+
* @param target 全屏按钮
|
139
|
+
* @returns 全屏的父元素
|
140
|
+
*/ export const getFullScreenWrap = (target)=>{
|
141
|
+
let parentElement = target.parentElement;
|
142
|
+
while(parentElement && !(parentElement === null || parentElement === void 0 ? void 0 : parentElement.classList.contains('full-screen-wrap'))){
|
143
|
+
parentElement = parentElement === null || parentElement === void 0 ? void 0 : parentElement.parentElement;
|
144
|
+
}
|
145
|
+
return parentElement;
|
146
|
+
};
|
147
|
+
/**
|
148
|
+
* 获取用户头像
|
149
|
+
* @param username 用户名
|
150
|
+
* @returns 头像地址
|
151
|
+
*/ export function getUserImageUrl(username = '') {
|
152
|
+
var _process_env_BK_USER_IMAGE_URL;
|
153
|
+
if (username === 'admin') {
|
154
|
+
return userImageUrl;
|
155
|
+
}
|
156
|
+
return ((_process_env_BK_USER_IMAGE_URL = process.env.BK_USER_IMAGE_URL) === null || _process_env_BK_USER_IMAGE_URL === void 0 ? void 0 : _process_env_BK_USER_IMAGE_URL.replace('{placeholder}', username)) || userImageUrl;
|
157
|
+
}
|
158
|
+
/**
|
159
|
+
* 处理头像加载失败的场景
|
160
|
+
*/ export function handleImageError(event) {
|
161
|
+
const { target } = event;
|
162
|
+
if (target.naturalWidth === 0) {
|
163
|
+
// 使用fetch API检查图片URL
|
164
|
+
fetch(target.src, {
|
165
|
+
method: 'HEAD',
|
166
|
+
credentials: 'include',
|
167
|
+
redirect: 'manual'
|
168
|
+
}).then((response)=>{
|
169
|
+
if (response.type === 'opaqueredirect') {
|
170
|
+
// 检测到重定向,调用登录方法
|
171
|
+
emitEvent(EventType.Unlogin);
|
172
|
+
}
|
173
|
+
}).catch((error)=>{
|
174
|
+
console.error('Failed to check image status:', error);
|
175
|
+
});
|
176
|
+
}
|
177
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { defineComponent as _defineComponent } from 'vue';
|
2
|
+
import { mergeProps as _mergeProps, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
3
|
+
const _hoisted_1 = [
|
4
|
+
"src"
|
5
|
+
];
|
6
|
+
import fallbackPng from '../../assets/svg/picture-fail.svg';
|
7
|
+
export default /*@__PURE__*/ _defineComponent({
|
8
|
+
props: {
|
9
|
+
url: {},
|
10
|
+
size: {}
|
11
|
+
},
|
12
|
+
setup (__props) {
|
13
|
+
const handleImageError = (e)=>{
|
14
|
+
const target = e.target;
|
15
|
+
target.src = fallbackPng;
|
16
|
+
};
|
17
|
+
return (_ctx, _cache)=>{
|
18
|
+
return /http(s)?:\/\//.test(_ctx.url) ? (_openBlock(), _createElementBlock("img", _mergeProps({
|
19
|
+
key: 0
|
20
|
+
}, _ctx.$attrs, {
|
21
|
+
src: _ctx.url,
|
22
|
+
style: {
|
23
|
+
width: `${_ctx.size}px`,
|
24
|
+
height: `${_ctx.size}px`
|
25
|
+
},
|
26
|
+
onError: handleImageError
|
27
|
+
}), null, 16 /* FULL_PROPS */ , _hoisted_1)) : (_openBlock(), _createElementBlock("i", _mergeProps({
|
28
|
+
key: 1
|
29
|
+
}, _ctx.$attrs, {
|
30
|
+
class: `bkaidev-icon bkaidev-${_ctx.url}`,
|
31
|
+
style: {
|
32
|
+
fontSize: `${_ctx.size}px`
|
33
|
+
}
|
34
|
+
}), null, 16 /* FULL_PROPS */ ));
|
35
|
+
};
|
36
|
+
}
|
37
|
+
});
|
@@ -0,0 +1,6 @@
|
|
1
|
+
interface IProps {
|
2
|
+
url: string;
|
3
|
+
size: number;
|
4
|
+
}
|
5
|
+
declare const _default: import("vue").DefineComponent<IProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<IProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
6
|
+
export default _default;
|
@@ -0,0 +1,205 @@
|
|
1
|
+
import { defineComponent as _defineComponent } from 'vue';
|
2
|
+
import { normalizeClass as _normalizeClass, createVNode as _createVNode, createElementVNode as _createElementVNode, unref as _unref, withDirectives as _withDirectives, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, createElementBlock as _createElementBlock } from "vue";
|
3
|
+
const _hoisted_1 = {
|
4
|
+
class: "quill-container"
|
5
|
+
};
|
6
|
+
import { bkTooltips as vBkTooltips } from 'bkui-vue';
|
7
|
+
import { Close } from '../../../dist/node_modules/bkui-vue/lib/icon/index.js';
|
8
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue';
|
9
|
+
import RenderDrag from './render-drag.vue.js';
|
10
|
+
import RenderQuill from './render-quill.vue.js';
|
11
|
+
import { SessionContentRole } from '../../types/enum.js';
|
12
|
+
export default /*@__PURE__*/ _defineComponent({
|
13
|
+
props: {
|
14
|
+
isChatting: {
|
15
|
+
type: Boolean
|
16
|
+
},
|
17
|
+
width: {},
|
18
|
+
dragPosition: {},
|
19
|
+
id: {},
|
20
|
+
supportTools: {
|
21
|
+
type: Boolean
|
22
|
+
},
|
23
|
+
supportImage: {
|
24
|
+
type: Boolean
|
25
|
+
},
|
26
|
+
sessionId: {},
|
27
|
+
placeholder: {},
|
28
|
+
sessionContents: {}
|
29
|
+
},
|
30
|
+
emits: [
|
31
|
+
"send"
|
32
|
+
],
|
33
|
+
setup (__props, { emit: __emit }) {
|
34
|
+
const props = __props;
|
35
|
+
const emit = __emit;
|
36
|
+
const vm = getCurrentInstance();
|
37
|
+
const quillRef = ref();
|
38
|
+
const textHeight = ref(120);
|
39
|
+
const defaultHeight = ref(120);
|
40
|
+
const prompt = ref('');
|
41
|
+
const isUploadingImage = ref(false);
|
42
|
+
const disableTips = computed(()=>{
|
43
|
+
if (!prompt.value) {
|
44
|
+
return '请输入 Prompt 后再发送';
|
45
|
+
}
|
46
|
+
if (!prompt.value.trim()) {
|
47
|
+
return '输入的 Prompt 不能只包含空格';
|
48
|
+
}
|
49
|
+
if (props.isChatting) {
|
50
|
+
return '当前会话进行中,请等待会话结束后再发送';
|
51
|
+
}
|
52
|
+
if (isUploadingImage.value) {
|
53
|
+
return '正在上传图片,请等待图片上传完成后再发送';
|
54
|
+
}
|
55
|
+
return '';
|
56
|
+
});
|
57
|
+
const placeholder = computed(()=>{
|
58
|
+
let placeholder = '请输入 Prompt';
|
59
|
+
if (props.supportImage) {
|
60
|
+
placeholder += '\n您可以粘贴并发送图片,以查询图片相关问题';
|
61
|
+
}
|
62
|
+
if (props.supportTools) {
|
63
|
+
placeholder += '\n您可以键入“@”来快速获取该会话绑定的“知识和工具”名称来进行问答';
|
64
|
+
}
|
65
|
+
if (props.placeholder) {
|
66
|
+
placeholder = props.placeholder;
|
67
|
+
}
|
68
|
+
return placeholder;
|
69
|
+
});
|
70
|
+
const autoFocus = ()=>{
|
71
|
+
nextTick(()=>{
|
72
|
+
var _quillRef_value;
|
73
|
+
(_quillRef_value = quillRef.value) === null || _quillRef_value === void 0 ? void 0 : _quillRef_value.focus();
|
74
|
+
});
|
75
|
+
};
|
76
|
+
const handleChangeTextHeight = ()=>{
|
77
|
+
nextTick(()=>{
|
78
|
+
var _vm_proxy;
|
79
|
+
const elm = vm === null || vm === void 0 ? void 0 : (_vm_proxy = vm.proxy) === null || _vm_proxy === void 0 ? void 0 : _vm_proxy.$el.nextElementSibling.querySelector('.send-prompt-container .ql-editor');
|
80
|
+
if ((elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > defaultHeight.value && prompt.value) {
|
81
|
+
textHeight.value = elm.scrollHeight <= 400 ? elm.scrollHeight : 400;
|
82
|
+
} else {
|
83
|
+
textHeight.value = defaultHeight.value;
|
84
|
+
}
|
85
|
+
});
|
86
|
+
};
|
87
|
+
// 从历史里面选择文本
|
88
|
+
const handleChooseHistory = ()=>{
|
89
|
+
var _props_sessionContents;
|
90
|
+
const userSessionContents = ((_props_sessionContents = props.sessionContents) === null || _props_sessionContents === void 0 ? void 0 : _props_sessionContents.filter((sessionContent)=>[
|
91
|
+
SessionContentRole.User,
|
92
|
+
SessionContentRole.Role,
|
93
|
+
SessionContentRole.UserImage
|
94
|
+
].includes(sessionContent.role))) || [];
|
95
|
+
const { content } = userSessionContents[userSessionContents.length - 1];
|
96
|
+
if (content !== prompt.value) {
|
97
|
+
var _quillRef_value;
|
98
|
+
(_quillRef_value = quillRef.value) === null || _quillRef_value === void 0 ? void 0 : _quillRef_value.setText(content);
|
99
|
+
}
|
100
|
+
};
|
101
|
+
const handleKeyDown = (event)=>{
|
102
|
+
var _props_sessionContents;
|
103
|
+
// 数据
|
104
|
+
const isEmpty = prompt.value === '' || prompt.value === undefined;
|
105
|
+
// 状态
|
106
|
+
const isSpecialEnter = event.key === 'Enter' && !event.shiftKey && !event.ctrlKey && !event.metaKey && !event.isComposing;
|
107
|
+
const isShowUpHistory = event.key === 'ArrowUp' && ((_props_sessionContents = props.sessionContents) === null || _props_sessionContents === void 0 ? void 0 : _props_sessionContents.length) && isEmpty;
|
108
|
+
if (isSpecialEnter) {
|
109
|
+
event.preventDefault();
|
110
|
+
handleSendPrompt();
|
111
|
+
}
|
112
|
+
if (isShowUpHistory) {
|
113
|
+
handleChooseHistory();
|
114
|
+
}
|
115
|
+
};
|
116
|
+
const handleChangeInput = (val)=>{
|
117
|
+
prompt.value = val;
|
118
|
+
};
|
119
|
+
const handleClearUserPrompt = ()=>{
|
120
|
+
var _quillRef_value;
|
121
|
+
(_quillRef_value = quillRef.value) === null || _quillRef_value === void 0 ? void 0 : _quillRef_value.setText('');
|
122
|
+
};
|
123
|
+
const handleSendPrompt = ()=>{
|
124
|
+
var // 清空
|
125
|
+
_quillRef_value;
|
126
|
+
// 没内容或执行中不做操作
|
127
|
+
if (disableTips.value) return;
|
128
|
+
// 发送
|
129
|
+
emit('send', prompt.value);
|
130
|
+
(_quillRef_value = quillRef.value) === null || _quillRef_value === void 0 ? void 0 : _quillRef_value.setText('');
|
131
|
+
};
|
132
|
+
watch(()=>prompt.value, (val)=>{
|
133
|
+
handleChangeTextHeight();
|
134
|
+
});
|
135
|
+
onMounted(autoFocus);
|
136
|
+
return (_ctx, _cache)=>{
|
137
|
+
return _openBlock(), _createElementBlock("section", {
|
138
|
+
class: _normalizeClass([
|
139
|
+
'send-prompt-container',
|
140
|
+
_ctx.$attrs.class
|
141
|
+
]),
|
142
|
+
style: _normalizeStyle({
|
143
|
+
'--text-height': textHeight.value + 'px',
|
144
|
+
'--default-height': defaultHeight.value + 'px',
|
145
|
+
'--textarea-bottom': -textHeight.value + 'px'
|
146
|
+
})
|
147
|
+
}, [
|
148
|
+
_createElementVNode("section", _hoisted_1, [
|
149
|
+
_createVNode(RenderQuill, {
|
150
|
+
"is-uploading-image": isUploadingImage.value,
|
151
|
+
"onUpdate:isUploadingImage": _cache[0] || (_cache[0] = ($event)=>isUploadingImage.value = $event),
|
152
|
+
value: prompt.value,
|
153
|
+
placeholder: placeholder.value,
|
154
|
+
"session-id": _ctx.sessionId,
|
155
|
+
"support-image": _ctx.supportImage,
|
156
|
+
class: _normalizeClass({
|
157
|
+
'send-prompt': true
|
158
|
+
}),
|
159
|
+
ref_key: "quillRef",
|
160
|
+
ref: quillRef,
|
161
|
+
onKeydown: handleKeyDown,
|
162
|
+
onChange: handleChangeInput
|
163
|
+
}, null, 8 /* PROPS */ , [
|
164
|
+
"is-uploading-image",
|
165
|
+
"value",
|
166
|
+
"placeholder",
|
167
|
+
"session-id",
|
168
|
+
"support-image"
|
169
|
+
])
|
170
|
+
]),
|
171
|
+
_withDirectives(_createElementVNode("i", {
|
172
|
+
class: _normalizeClass({
|
173
|
+
'bkaidev-icon bkaidev-fasong': true,
|
174
|
+
'disable': disableTips.value
|
175
|
+
}),
|
176
|
+
onMousedown: handleSendPrompt
|
177
|
+
}, null, 34 /* CLASS, NEED_HYDRATION */ ), [
|
178
|
+
[
|
179
|
+
_unref(vBkTooltips),
|
180
|
+
{
|
181
|
+
content: disableTips.value,
|
182
|
+
disabled: !disableTips.value
|
183
|
+
}
|
184
|
+
]
|
185
|
+
]),
|
186
|
+
prompt.value ? (_openBlock(), _createBlock(_unref(Close), {
|
187
|
+
key: 0,
|
188
|
+
class: "show-clear-only-hover bk-input--clear-icon bk-input--suffix-icon clear-icon",
|
189
|
+
onClick: handleClearUserPrompt
|
190
|
+
})) : _createCommentVNode("v-if", true),
|
191
|
+
_createVNode(RenderDrag, {
|
192
|
+
"default-height": defaultHeight.value,
|
193
|
+
"onUpdate:defaultHeight": _cache[1] || (_cache[1] = ($event)=>defaultHeight.value = $event),
|
194
|
+
"text-height": textHeight.value,
|
195
|
+
"onUpdate:textHeight": _cache[2] || (_cache[2] = ($event)=>textHeight.value = $event),
|
196
|
+
position: _ctx.dragPosition
|
197
|
+
}, null, 8 /* PROPS */ , [
|
198
|
+
"default-height",
|
199
|
+
"text-height",
|
200
|
+
"position"
|
201
|
+
])
|
202
|
+
], 6 /* CLASS, STYLE */ );
|
203
|
+
};
|
204
|
+
}
|
205
|
+
});
|